#include <stddef.h>
#include <GL/glew.h>
#include "../Core/Assert.h"
#include "RenderTarget.h"


RenderTarget::RenderTarget(Format format, size_t width, size_t height)
    : width(width)
    , height(height)
{
    GLenum glFormat = GL_DEPTH_STENCIL;
    switch (format)
    {
    case kDepthStencil: glFormat = GL_DEPTH_STENCIL; break;
    default: Fatal("Invalid format");
    }
    glGenRenderbuffers(1, &handle);
    glBindRenderbuffer(GL_RENDERBUFFER, handle);
    glRenderbufferStorage(GL_RENDERBUFFER, glFormat, width, height);
}


RenderTarget::~RenderTarget()
{
    glDeleteRenderbuffers(1, &handle);
}
